package com.briup.product_my.controller;

import com.briup.product_my.domain.DiseaseRecord;
import com.briup.product_my.domain.ext.DiseaseRecordExt;
import com.briup.product_my.result.Result;
import com.briup.product_my.service.DiseaseService;
import com.github.pagehelper.PageInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @Auther: xiongwenbin
 * @Date: 2024/8/22-08-22-下午3:23
 * @Description: com.briup.product_my.controller
 */
@RestController
@RequestMapping("/diseaseRecord")
@Api(tags = "病症记录模块")
public class DiseaseController {
    @Autowired
    private DiseaseService diseaseService;

    @GetMapping
    @ApiOperation(value = "获取病症记录列表")
    public Result getDiseaseList(@RequestParam(value = "drDId",required = false) String drDId,@RequestParam(value = "drStatus",required = false) String drStatus ,@RequestParam(value = "pageNum",required = false,defaultValue = "1") Integer page,@RequestParam(value = "pageSize",required = false) Integer pageSize){
        PageInfo<DiseaseRecordExt> pageInfo = diseaseService.findAll(page,pageSize,drDId,drStatus);
        return Result.success(pageInfo);
    }
    @GetMapping("/queryAllDisease")
    @ApiOperation(value = "获取病症记录列表")
    public Result queryAllDisease(){
        return Result.success(diseaseService.queryAllDisease());
    }
    @PostMapping("/saveOrUpdate")
    @ApiOperation(value = "保存或更新病症记录")
    public Result saveOrUpdate(@RequestBody DiseaseRecord diseaseRecord){
        diseaseService.saveOrUpdate(diseaseRecord);
        return Result.success();
    }
    @DeleteMapping("/deleteById/{id}")
    public Result delete(@PathVariable("id") String id){
        diseaseService.delete(id);
        return Result.success();
    }
    @DeleteMapping("/deleteByIdAll")
    public Result deleteAll(@RequestBody Integer[] Ids){
        diseaseService.deleteAll(Ids);
        return Result.success();
    }
}
